using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;
using System.Data.SqlClient;

public partial class T_ReadKML : MyPage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Locations(object sender, EventArgs e)
    {
        /*XmlDocument doc = new XmlDocument();
        doc.Load(Server.MapPath("London Boroughs Loc.xml"));

        XmlNodeList locations = doc.GetElementsByTagName("Placemark");

        foreach (XmlNode location in locations)
        {
            string qstring = String.Format("INSERT INTO cm_cities (ct_name, ct_lat, ct_long, ct_icon_lat, ct_icon_long, ct_zoom, ct_icon, ct_site, ct_parent) VALUES ('{0}', {2}, {1}, {2}, {1}, 12, 'Police_uk', 2, 6)", location["name"].InnerText, location["Point"].InnerText.Split(',')[0], location["Point"].InnerText.Split(',')[1]);

            Response.Write(qstring + "<br><br>");

            SqlCommand sp = new SqlCommand(qstring, conn);
            sp.CommandType = CommandType.Text;
            conn.Open();
            sp.ExecuteNonQuery();
            conn.Close();
        }*/
    }

    protected void Borders(object sender, EventArgs e)
    {
        XmlDocument doc = new XmlDocument();
        doc.Load(Server.MapPath("London Boroughs.xml"));

        XmlNodeList locations = doc.GetElementsByTagName("Placemark");

        foreach (XmlNode location in locations)
        {
            SqlCommand sp = new SqlCommand("cm_klm_update", conn);
            sp.CommandType = CommandType.StoredProcedure;
                sp.Parameters.AddWithValue("@KLM", location["Polygon"].InnerText.Substring(1).Trim());
                sp.Parameters.AddWithValue("@ct_name", location["name"].InnerText);
            conn.Open();
            Response.Write(String.Format("<b>{1}:</b> border of {0} points created <br /> ", (Int32)sp.ExecuteScalar(), location["name"].InnerText));
            conn.Close();
        }
    }
}
